<%-- 
    Document   : UploadAction
    Created on : 16 Des 12, 19:11:14
    Author     : SONY
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Klinik Gizi Online</title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <link href="apuppy_style.css" rel="stylesheet" type="text/css" />
        <script language="javascript" type="text/javascript">
            function clearText(field)
            {
                if (field.defaultValue == field.value) field.value = '';
                else if (field.value == '') field.value = field.defaultValue;
            }
        </script>
    </head>
    <body>
        <div id="templatemo_header_wrapper">

            <div id="templatemo_header">

                <div id="site_title">
                    <h1><a href="index.jsp" target="_parent ">
                            Apuppy
                        </a></h1>
                </div>

                <div id="templatemo_menu">
                    <ul>
                        <li><a href="index.jsp" class="current">Home</a></li>
                        <li><a href="profile.jsp" target="_parent">profile</a></li>
                        <li><a href="formPendaftaran.jsp" target="_parent">pendaftaran</a></li>
                    </ul>    	
                </div> <!-- end of templatemo_menu -->



                <div class="cleaner"></div>
            </div> <!-- end of templatemo_header -->

        </div> 
        <!-- end of templatemo_header_wrapper -->

        <div id="templatemo_content_wrapper">

            <div id="">

                <div class="content_section">
                    <%
                        aktor.DataBaseConnection conn = new aktor.DataBaseConnection();
                        conn.getDBConnection();
                    %>
                    <jsp:useBean id="ar" scope="session" class="aktor.artikel"/>

                    <%@ page import="java.io.*" %>
                    <%@ page import="com.oreilly.servlet.MultipartRequest" %>

                    <%
                        /*
                         * method dibawah digunakan untuk mengambil parameter untuk mengambil judul,
                         * pengarang, penerbit, cover dan pdf yang telah diinputkan dan
                         * memasukkannya ke dalam bean.
                         */
                        String contentType = request.getContentType();
                        if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
                            MultipartRequest mp = new MultipartRequest(request, request.getRealPath("./Gambar"), 1024 * 1024 * 1024);

                            ar.setJudul_Artikel(mp.getParameter("JudulArtikel"));
                            ar.setCover("./Gambar/" + mp.getOriginalFileName("Cover"));
                            ar.setFileUpload("./Gambar/" + mp.getOriginalFileName("FileUpload"));
                        }
                    %>

                    <%
                        /*
                         * method dibawah digunakan untuk mengambil informasi dari dalam java bean
                         * dan kemudian informasi tersebut dimasukkan ke dalam database.
                         */
                        try {

                            String query = "INSERT INTO ARTIKEL(ID_ARTIKEL,JUDUL_ARTIKEL,COVER,FILEUPOLAD) VALUES "
                                    + "('" + ar.ID_Artikel() + "' , '" + ar.getJudul_Artikel() + "' , '" + ar.getCover() + "', '" + ar.getFileUpload() + "')";
                            java.sql.Statement statement = conn.getConnection().createStatement();
                            int s = statement.executeUpdate(query);

                            System.out.println("Data berhasil dimasukkan \n");

                            statement.close();
                        } catch (Exception ex) {
                            out.println("message1: " + ex.getMessage());
                        }
                    %>
                    <html>
                        <head>
                            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                            <title>Data Upload</title>
                        </head>
                        <body>

                        <center><<%=ar.aksesDatabase()%></center>

                        </body>
                    </html>
                </div>




            </div> 




        </div> <!-- end of content -->




        <div id="templatemo_footer">

            <ul class="footer_menu">

            </ul>

            Copyright ÃÂ© 2048 <a href="#">Apuppy 2010</a> | 
            Designed by <a href="" target="_parent">Apuppy Klinik Gizi Online</a> | 
            <a href="https://www.usd.ac.id">www.usd.ac.id</a>
        </div> <!-- end of templatemo_footer -->
    </body>
</html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <frameset rows="25%,65%,10%" frameborder="no">
        <frame src="header.jsp" noresize="noresize" scrolling="no"/>
        <frameset cols="350%,100%,16%" frameborder="no" >
            <frame src ="HalamanUtama.jsp"/>
        </frameset>
        <frame src="footer.jsp" noresize="noresize" scrolling="no"/>
    </frameset> 
</head>
</html>